Developer Documentation

QuickTime 4 API Documentation

Inside Macintosh: Memory

Previous | Chapter Top | Chapter Contents | Next |

Setting and Restoring the A5 Register

Any code that runs asynchronously or as a callback routine and that accesses the calling application's A5 world must ensure that the A5 register correctly points to the boundary between the application parameters and the application global variables. To accomplish this, you can call the SetCurrentA5 function at the beginning of any asynchronous or callback code that isn't executed at interrupt time. If the code is executed at interrupt time, you must use the SetA5 function to set the value of the A5 register. (You determine this value at noninterrupt time by calling SetCurrentA5 .) Then you must restore the A5 register to its previous value before the interrupt code returns.

SetCurrentA5

You can use the SetCurrentA5 function to get the current value of the system global variable CurrentA5 .

FUNCTION SetCurrentA5: LongInt;

DESCRIPTION

The SetCurrentA5 function does two things: First, it gets the current value in the A5 register and returns it to your application. Second, SetCurrentA5 sets register A5 to the value of the low-memory global variable CurrentA5 . This variable points to the boundary between the parameters and global variables of the current application.

SPECIAL CONSIDERATIONS

You cannot reliably call SetCurrentA5 in code that is executed at interrupt time unless you first guarantee that your application is the current process (for example, by calling the Process Manager function GetCurrentProcess ). In general, you should call SetCurrentA5 at noninterrupt time and then pass the returned value to the interrupt code.

ASSEMBLY-LANGUAGE INFORMATION

You can access the value of the current application's A5 register with the low-memory global variable CurrentA5 .

SetA5

In interrupt code that accesses application global variables, use the SetA5 function first to restore a value previously saved using SetCurrentA5 , and then, at the end of the code, to restore the A5 register to the value it had before the first call to SetA5 .

FUNCTION SetA5 (newA5: LongInt): LongInt;
newA5
The value to which the A5 register is to be changed.

DESCRIPTION

The SetA5 function performs two tasks: it returns the address in the A5 register when the function is called, and it sets the A5 register to the address specified in newA5 .


© 1997 Apple Computer, Inc.

Previous | Chapter Top | Chapter Contents | Next